function Fibonacci = vecFib(num1, num2, num, flag)
%Function name: vecFib
%   Calculates the Fibonacci series.

    %If flag==1, will output a row vector containing the Fibonacci
    %series until the "num"-th Fibonacci number.
    
    if flag==1
        Fibonacci = zeros(1,num);
 
        Fibonacci(1) = num1;
        Fibonacci(2) = num2;
        
        for n=3:num
            Fibonacci(n)=Fibonacci(n-1)+Fibonacci(n-2); 
    
        end
    end
    
    %If flag==2, will calculate a row vector containing the Fibonacci
    %series with all numbers smaller than "num".
    
    if flag==2
        
        tempFibonacci = zeros(1,2);
        Fibonacci = zeros(1,2);
        
        tempFibonacci(1) = num1;
        tempFibonacci(2) = num2;
        n=2;
        
        while(tempFibonacci(n)<num)
            
            Fibonacci=tempFibonacci;
            n=n+1;
            %Lengthens size of tempFibonacci by 1, and associates all
            %values to that of Fibonacci, except the last, which is zero.
            
            tempFibonacci=zeros(1,n);
            longFibonacci = resampVec(tempFibonacci, Fibonacci);
            tempFibonacci = tempFibonacci + longFibonacci;
            
            %Calculates nth Fibonacci number.
            tempFibonacci(n) = tempFibonacci(n-1) + tempFibonacci(n-2);
                        
        end
    end
    
end

